home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!xs4all!falstaff
- From: falstaff@xs4all.nl (Falstaff)
- Newsgroups: comp.lang.c
- Subject: Re: goto
- Date: 14 Mar 1996 19:55:02 GMT
- Organization: XS4ALL, networking for the masses
- Message-ID: <4i9tim$see@news.xs4all.nl>
- References: <Pine.OSF.3.91.960313102715.10701D-100000@io.UWinnipeg.ca>
- NNTP-Posting-Host: xs1.xs4all.nl
- X-Newsreader: NN version 6.5.0 #666 (NOV)
-
- Bill Simpson <wsimpson@uwinnipeg.ca> writes:
-
- >There was a goto thread lately, and my problem is to state this algorithm
- >cleanly without gotos (which I think is easy, but my attempts have been
- >failures).
-
- >0. x=0;
- >1. x+=erand(maxmean);
- >2. if (urand2()>rate(x)/maxrate)
- > goto step 1
- >3. if (x<=XMAX)
- > {
- > setdot(x,y,z);
- > goto step 1
- > }
-
- One possibility:
-
- for(x=0;;)
- { x+=erand(maxmean);
- if(urand2()>rate(x)/maxrate)
- continue;
- if(x>XMAX)
- break;
-
- setdot(x,y,z);
- }
-
- Frank
- --
- The famous GIICM now on line: http://www.xs4all.nl/~falstaff/GIICM.html
- ------------------------------------------------------------------------
- Frank A. Vorstenbosch +31-(70)-355 5241 falstaff@xs4all.nl
-